import 'package:dio/dio.dart';

BaseOptions options = new BaseOptions(
    baseUrl: "http://192.168.31.245:7300/mock/5f1a57894cfd592b919d9abf/flutter_hello_world",
    connectTimeout: 5000,
    receiveTimeout: 3000,
);

class Api {
  Dio dio;
  Api(){
    this.dio = new Dio(options);
    this.dio.interceptors.add(
      InterceptorsWrapper(
        onRequest:(RequestOptions options) async {
          return options; //continue
        },
        onResponse:(Response response) async {
          return response; // continue
        },
        onError: (DioError e) async {
          return  e;//continue
        }
      )
    );
  }
  Future<Response> login({String username, String password}) {
    return this.dio.post("/login", data: {"username": username, "password": password});
  }
  Future<Response> messageList() {
    return this.dio.get("/message-list");
  }
}